package com.ftqh.core.jpa.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.support.SimpleJpaRepository;

import javax.persistence.EntityManager;
import java.io.Serializable;

import static com.ftqh.core.jpa.repository.specs.CustomerSpecs.byAuto;

public class BaseRepositoryImpl <T, ID extends Serializable>
					extends SimpleJpaRepository<T, ID> implements BaseRepository<T,ID> {
	
	private final EntityManager entityManager;
	
	public BaseRepositoryImpl(Class<T> domainClass, EntityManager entityManager) {
		super(domainClass, entityManager);
		this.entityManager = entityManager;

	}
	public void update(T example){
		entityManager.merge(example);
	}
	public Page<T> findByAuto(T example, Pageable pageable) {
		return findAll(byAuto(entityManager, example),pageable);
	}


}
